home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir37 / shl.zip / FOXPRO.ZIP / Q_HELP.TXT < prev    next >
Text File  |  1990-10-17  |  11KB  |  305 lines

  1. This file describes the custom expression building facility.
  2.  
  3. The facility consists of two parts. The Data_bld program and the expression
  4. builder programs.
  5.  
  6. 1.Data_bld program. 
  7.         
  8.   The Data_bld.prg is used by the developer to create the necessary data 
  9.   files (DBF) if they have not been created.
  10.     
  11.   Those DBF files are Q_DATA,Q_EXPR,Q_PHRASE and a file to be named by 
  12.   the developer that contains the field lookup    data for the expression 
  13.   builder picklist. 
  14.  
  15.  
  16.   Q_DATA.DBF is a data dictionary that the data_bld.prg builds from the
  17.   current environment. Fields from the master data base and all related
  18.   data bases (directly related or indirectly related) are included.
  19.   Unrelated data files are not included.
  20.  
  21.   When the data_bld program is started, the developer is given a chance to
  22.   re-label the data base names for use in expression picklists. This should
  23.   make it easier for the user to understand what they are picking.
  24.   Example: Re-label CUST(DBF) to Customer.
  25.  
  26.  
  27.   The developer is given a chance to change (browse) the Field_label 
  28.   and the picture clause for each field used in the expression builder. 
  29.   Fields may also be removed from the list by deleting them. This will
  30.   remove unnecessary fields or fields that would be confusing to the user.
  31.  
  32.  
  33.  
  34.   Structure for database : q_data.dbf
  35.   Field  Field Name  Type       Width    Dec
  36.      1  FIELD_NAME  Character     20
  37.      2  FIELDLABEL  Character     30
  38.      3  FIELD_TYPE  Character      1
  39.      4  FIELD_LEN   Numeric        3      0
  40.      5  FIELD_PICT  Character     25
  41.      6  FIELD_DEC   Numeric        3      0
  42.   ** Total **                   00083
  43.  
  44.  
  45.   To re-edit the Q_data data dictionary just rerun the Data_bld program.
  46.   The Data_bld.prg will continue  to use the existing q_data.dbf. This
  47.   allows correction of mistakes in picture clauses and field labels without
  48.   having to start over again. (NOTE- Mistakes in picture clauses is the
  49.   most likely cause for the expression builder to bomb.)
  50.  
  51.  
  52.   To make a new picklist program and data file for another view/environment,
  53.   just erase or rename the q_data.dbf and open the new files before running 
  54.   the Data_bld program. Be sure to set the file relations.
  55.  
  56.  
  57.   Also, Data_bld.prg will write a program file (named by the developer) that 
  58.   will contain custom code for picklist menus for that    particular 
  59.   application environment, and create a data file (DBF) that contains 
  60.   the data necessary for a picklist. The data file for the picklist will be
  61.   given the same name as the written program so the developer will know
  62.   which picklist program goes with which data_file.
  63.   Example: Program= "QCUSTOM.PRG"  DBF= "QCUSTOM.DBF")
  64.  
  65.   The custom datafile will have the same structure as q_data.
  66.  
  67.   One of the parameters for the written program is "data_pop". If data_pop
  68.   is passed as true(.t.), the program will use code that uses DEFINE POPUP
  69.   FIELD for the picklist. If you prefer to uses array style menus(i.e....
  70.   not enough open work areas), pass data_pop as false (.f.). Depending on 
  71.   the size of the data files in the view, you may have to increase 
  72.   the MVARSIZ in Config.FP. Large DBFs create large memory consuming arrays.
  73.  
  74.  
  75.   The expression builder requires a minimum of 2 open workareas for Q_EXPR
  76.   and Q_PHRASE. It requires a 3rd workarea if you use DEFINE POPUP FIELD 
  77.   (DATA_POP=.t.) for the picklist. The default value for data_pop is true.
  78.  
  79.   To change the data_pop value- change "dbf_pop = .t." to "dbf_pop =  .f."
  80.   in the expr_bld procedure.
  81.  
  82.     dbf_pop=.t.   && if .t. use DEFINE POPUP FIELD picklist
  83.     do (qfile) with d_name,dlabel,d_pict,d_type,d_len,d_dec,dbf_pop
  84.  
  85.  
  86.  
  87.   The Q_EXPR and Q_PHRASE data files contain the expression information.
  88.   Each record in q_expr contains the information on one expression. The
  89.   expression values (phrases) for one expression are contained in 1 or more 
  90.   q_phrase records. 
  91.  
  92.   Of particular interest in the q_expr DBF is the field entitled "PROGRAM".
  93.   This field is used to tell the expresion builder the current environment.
  94.   It is passed as a parameter to the main program ("EXPRMENU.PRG").
  95.  
  96.   Examples:  my_expr=exprmenu('REPORT','QCUSTOM').
  97.              my_expr=exprmenu(PROGRAM(),'QCUSTOM').
  98.  
  99.  
  100.   NOTE: The 2nd parameter is the name of the custom program created by 
  101.         the data_bld program that contains the picklist for that
  102.         environment.
  103.  
  104.   The q_expr DBF (and q_phrase.dbf) can store the expressions for an entire 
  105.   application, but the "PROGRAM" field tells the expression builder which 
  106.   expressions are appropriate for that particular environment and does not
  107.   show the user the other expressions. 
  108.  
  109.   HINT: A USER ID could be passed as the 1st parameter. This would allow
  110.   each user of the application to have their own set of selection criteria.
  111.   The parameter must be no more than 8 characters long. If there are
  112.   multiple environments in the application, then perhaps part of a USER ID
  113.   plus enough of a character string to identify the environment.
  114.   
  115.   Example: USER ID="1234"  Environment="Reports"  
  116.            Parameter="1234_REP"
  117.           
  118.  
  119.   Structure for database : q_expr.dbf
  120.   Field  Field Name  Type       Width    Dec
  121.      1  EXPR_ID     Character      6
  122.      2  EXPR_NAME   Character     40
  123.      3  PROGRAM     Character      8        && identifies environment of
  124.                                             && calling program
  125.  
  126.      4  FOX_EXPR    Logical        1        && is it a getexpr expression
  127.      5  IG_CASE     Logical        1        && ignore case for expression
  128.      6  EXPR        Memo          10        && store getexpr values
  129.   ** Total **                   00067
  130.  
  131.  
  132.   Structure for database : q_phrase.dbf
  133.   Field  Field Name  Type       Width    Dec
  134.      1  EXPR_ID     Character      6
  135.      2  PHRASE_NO   Numeric        2      0
  136.      3  OPERATOR    Character      2
  137.      4  CONNECTOR   Character      3
  138.      5  Q_FIELD     Character     20
  139.      6  Q_FLABEL    Character     30
  140.      7  Q_FTYPE     Character      1
  141.      8  Q_FLEN      Numeric        3      0
  142.      9  Q_FPICT     Character     25
  143.      10  Q_FDEC      Numeric        3      0
  144.      11  Q_DATA      Character    120
  145.      12  QD_CHOICE   Numeric        1      0
  146.      13  QM_CHOICE   Numeric        1      0
  147.      14  QY_CHOICE   Numeric        1      0
  148.      15  QD_EXPR     Character     30
  149.      16  QM_EXPR     Character     30
  150.      17  QY_EXPR     Character     30
  151.   ** Total **                   00309
  152.  
  153.  
  154.  
  155.  
  156. 2.Expression builder programs.
  157.  
  158.   Exprmenu.prg- main program for expression builder
  159.   
  160.  
  161.   ** The following programs have been bound into the Exprmenu program.
  162.   
  163.   Expr_bld.prg- add or edit expressions
  164.   
  165.   Expr_get.prg- builds complete expression from q_phrase records
  166.   
  167.   Qoperate.prg- displays expression operators and returns selected
  168.                 operator
  169.   
  170.   Op2phra.prg-  converts operator into a phrase
  171.                 Example: "==" to "is the same as"
  172.                 
  173.   Phra2op.prg-  converts phrases to operator symbols
  174.   
  175.   Q_date.prg-    builds variable date expression            
  176.   
  177.   
  178.  
  179.  
  180.   In the interest of speed, The EXPRMENU program does not maintain 
  181.   it's own indexes. Therefore, you will want to place the following code
  182.   in the program you use that rebuilds your application indexes.
  183.  
  184.       
  185.     USE Q_EXPR
  186.     INDEX ON PROGRAM+UPPER(EXPR_NAME) TO Q_EXPR 
  187.     INDEX ON EXPR_ID TO Q_ID 
  188.     USE
  189.     USE Q_PHRASE 
  190.     INDEX ON EXPR_ID+STR(1000+PHRASE_NO) TO Q_PHRASE
  191.     USE
  192.  
  193.   Also, indexes are created for the custom picklist DBFs. They may need
  194.   reindexing if problems arise. The indexes use the same name as the
  195.   custom DBF.
  196.   
  197.   Examples:
  198.     USE QCUSTOM
  199.     INDEX ON FIELDLABEL TO QCUSTOM
  200.     USE INVOICE
  201.     INDEX ON FIELDLABEL TO QINVOICE
  202.     USE
  203.  
  204. HOW TO USE THE EXPRESSION BUILDER
  205.  
  206.  
  207. 1.  Open the data files and set up the relations
  208. 2.  Make sure the master data base is selected.
  209.  
  210.  
  211.     USE PATIENT INDEX ID
  212.     USE ADDRESS INDEX ADD_ID IN 2
  213.     SET RELATION TO ADD_ID INTO ADDRESS
  214.     GO TOP
  215.     
  216.     DO DATA_BLD
  217.  
  218. 3.  Data_bld.prg will show the data file names ("PATIENT","ADDRESS")
  219.     and allow you to re-label them for the expression builder picklist.
  220.     
  221.  
  222. 4.  Data_bld.prg will build the data dictionary Q_DATA.DBF from all
  223.     fields in the patient and address files.      
  224.     
  225. 5.  Then you will be able to browse q_data and change the field_labels
  226.     and picture clauses for each field if desired, and delete unwanted
  227.     fields. These changes DO NOT affect the actual data files.
  228.     
  229.  
  230. 6.  It will then call the foxpro putfile() facility so you can name
  231.     the picklist program and data file. The default name supplied will
  232.     be the master DBF file name with a "Q" prefix.
  233.     Example: "QPATIENT"
  234.     
  235. 7.  The custom picklist program and data file are created.
  236.  
  237. 8.  Now you are ready to insert the expression builder into your programs.
  238.     
  239.     
  240. 9.    Be sure to look over the HELP topics when you start the exprmenu
  241.     program.
  242.  
  243.  
  244.     
  245. **********************************************************    
  246. ******* SAMPLE PROGRAM
  247. **********************************************************
  248.   SET TALK OFF
  249.   SET STATUS OFF
  250.  
  251. ** supply your files here
  252.  
  253.     USE PATIENT INDEX ID
  254.     USE ADDRESS INDEX ADD_ID IN 2
  255.     SET RELATION TO ADD_ID INTO ADDRESS
  256.  
  257. **
  258.  
  259.     GO TOP
  260.  
  261.  
  262.  
  263.   E_NAME='' && optional parameter that can pass the name of the selected
  264.             && expression back to the calling program                                          
  265.  
  266.  
  267. ** allow e_name to receive selected expression name from expremenu.prg.
  268.   
  269.   SET UDFPARMS TO REFERENCE
  270.  
  271.  
  272.   MY_EXPR=EXPRMENU(PROGRAM(),'QPATIENT',E_NAME)
  273.  
  274.   SET FILTER TO &MY_EXPR
  275.   GO TOP
  276.  
  277.   BROWSE
  278.         
  279.   IF '' <> MY_EXPR
  280.      COUNT TO HOW_MANY FOR &MY_EXPR
  281.      WAIT 'COUNT FOR '+ALLTRIM(E_NAME) +' IS '+ ;
  282.      ALLTRIM(STR(HOW_MANY)) + '. PRESS ANY KEY .. ' WINDOW
  283.   ENDIF
  284.   
  285.  
  286.   CLOSE DATABASES
  287.   RETURN
  288.  
  289.  
  290.  
  291. **************************************
  292. COMMAND LINE TEST
  293. **************************************
  294.  
  295. ** use this to see the actual code that is returned from exprmenu.prg
  296. ** xxxx is a substitute parameter. Be sure to use the same parameters
  297.    when you test it
  298. ** It doesn't have to be xxxx. Any character string will do.
  299.  
  300. ** Q?????? is the name of the picklist program you created with Data_bld
  301.  
  302. xx=MY_EXPR=EXPRMENU('XXXX','Q??????')
  303. ? xx
  304.  
  305.